/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "Cost")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cost.findAll", query = "SELECT c FROM Cost c"),
    @NamedQuery(name = "Cost.findByCostID", query = "SELECT c FROM Cost c WHERE c.costID = :costID"),
    @NamedQuery(name = "Cost.findByCostDesc", query = "SELECT c FROM Cost c WHERE c.costDesc = :costDesc")})
public class Cost implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CostID")
    private Integer costID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 80)
    @Column(name = "CostDesc")
    private String costDesc;
    @OneToMany(mappedBy = "bCost")
    private Collection<Beer> beerCollection;

    public Cost() {
    }

    public Cost(Integer costID) {
        this.costID = costID;
    }

    public Cost(Integer costID, String costDesc) {
        this.costID = costID;
        this.costDesc = costDesc;
    }

    public Integer getCostID() {
        return costID;
    }

    public void setCostID(Integer costID) {
        this.costID = costID;
    }

    public String getCostDesc() {
        return costDesc;
    }

    public void setCostDesc(String costDesc) {
        this.costDesc = costDesc;
    }

    @XmlTransient
    public Collection<Beer> getBeerCollection() {
        return beerCollection;
    }

    public void setBeerCollection(Collection<Beer> beerCollection) {
        this.beerCollection = beerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (costID != null ? costID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cost)) {
            return false;
        }
        Cost other = (Cost) object;
        if ((this.costID == null && other.costID != null) || (this.costID != null && !this.costID.equals(other.costID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.Cost[ costID=" + costID + " ]";
    }
    
}
